var _that;
var img_amt = wx.createAnimation({ duration: 500 });
function initAmtImg(target) {
  _that = target;
  _that.setData({
    amtImgs: []
  });
}

function addImg(url, top, left) {
  var imgs = _that.data.amtImgs;

  var topval = wx.getSystemInfoSync().windowHeight - 35;
  var leftval = 12;
  img_amt.left(leftval).top(topval).rotate(1080).step({ timingFunction: 'ease-out' });
  var imginfo = {
    img: url,
    top: top,
    left: left,
    isshow: true
  };
  imgs.push(imginfo);
  _that.setData({
    amtImgs: imgs
  });

  var amts = [];
  if (_that.data.amts) {
    amts = _that.data.amts;
  }
  amts.push(img_amt.export());
  _that.setData({
    amts: amts
  });

  var timeid = setTimeout(function () {
    clearTimeout(timeid);
    imginfo.isshow = false;
    _that.setData({
      amtImgs: imgs
    });
  }, 500);
}

module.exports = {
  init: initAmtImg,
  add: addImg
}